﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Script.Serialization;

namespace DoeLibsMVC
{
    /// <summary>
    /// this is a class for printing success/fail messages on the site after a redirect
    /// </summary>
    public class HttpMessage
    {

        public const string MESSAGE_COOKIE_NAME = "DoeLibsMsg";

        public bool Success { get; set; }
        public string Message { get; set; }

        public HttpMessage()
        {

        }

        public HttpMessage(string message, bool success)
            : this()
        {
            this.Success = success;
            this.Message = message;
        }

        public string getJson()
        {
            return new JavaScriptSerializer().Serialize(this);
        }

        public static HttpMessage getFromJson(string json)
        {
            HttpMessage msg = new JavaScriptSerializer().Deserialize<HttpMessage>(json);
            
            return msg;
        }
    }
}